All pastes #2054439 Raw Edit

Unnamed

public cpp v1 · immutable
#2054439 ·published 2011-05-06 04:37 UTC
rendered paste body
#define hibyte(a) (((a) >> 8) & 0xFF)#define lobyte(a) ((a) & 0xFF)#ifdef __DEBUG#include <iostream>#endif //__DEBUGtypedef /*unsigned*/ char byte; //1-bytetypedef /*unsigned*/ short word; //2-bytestypedef /*unsigned*/ long dword; //4-bytesstruct Regs16 {	word ax;	byte ah;	byte al;	word bx;	byte bh;	byte bl;	word cx;	byte ch;	byte cl;	word dx;	byte dh;	byte dl;	word si;	word di;	word bp;	word sp;	word cs;	word ds;	word es;	word fs;	word gs;	word ss;	word ip;		word flags;	} regs16;// Move functions: Intel stylevoid mov(word &dst, word src) {	dst = src;}void mov(byte &dst, byte src) {	dst = src;}//unsignedvoid movzx(word &dst, byte src) {	//mov but pad hi-byte with 0x00...}//signedvoid movsx(word &dst, byte src) {	//mov but pad with signededness 0xff?}void movsb() {	//Implement movsb	//move value at esi to edi}void xchg(word &dst, word &src) {	word tmp = dst;	dst = src;	src = tmp;}void xchg(byte &dst, byte &src) {	byte tmp = dst;	dst = src;	src = dst;}void lea(word &dst, word src) {	//Implement lea}///////////////////////////////////////////////// Mathvoid add(word &dst, word src) {	dst += src;}void add(byte &dst, byte src) {	dst += src;}void sub(word &dst, word src) {	dst -= src;}void sub(byte &dst, byte src) {	dst -= src;}void mul(byte src) {	//ax = al*src;}void mul(word src) {	//dx:ax = ax*src}//print hex to be template, set width to sizeof(T)*2int main() {	regs16.ax = 0x0141;	regs16.ah = hibyte(regs16.ax);	regs16.al = lobyte(regs16.ax);		#ifdef __DEBUG	std::cout << "AX = " << std::hex << regs16.ax << std::endl;	std::cout << "AH = " << std::hex << (int)regs16.ah << std::endl;	std::cout << "AL = " << std::hex << (int)regs16.al << std::endl;	#endif //__DEBUG	return 0;}